package com.example.a79273.nvshenyichu.model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2016/8/29.
 */
public class MatchTitleBean {

    /**
     * title : 全部
     * category : 0
     */

    private String title;
    private String category;

    public static MatchTitleBean objectFromData(String str) {

        return new Gson().fromJson(str, MatchTitleBean.class);
    }

    public static MatchTitleBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), MatchTitleBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<MatchTitleBean> arrayMatchTitleBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<MatchTitleBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<MatchTitleBean> arrayMatchTitleBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<MatchTitleBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }
}
